<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMemberCardsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $table_name = 'member_cards';
        Schema::create($table_name, function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('tenant_id')->index()->comment('租户ID');
            $table->tinyInteger('type')->comment('类型:1=计时,2=计次');
            $table->string('name', 100)->comment('名称');
            $table->decimal('price')->comment('价格');
            $table->decimal('market_price')->comment('市场价');
            $table->integer('days')->comment('有效期:0=无限');
            $table->integer('count')->default(0)->comment('有效次数');
            $table->string('cover_url')->default('')->comment('卡片封面图URL');
            $table->string('remark')->default('')->comment('备注');
            $table->boolean('is_enable')->default(true)->comment('是否启用');
            $table->integer('sort')->default(0)->comment('排序(值越大越靠前)');
            $table->timestamps();
        });
        add_table_comment($table_name, '会员卡表');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('member_cards');
    }
}
